package org.epes.laboratory.vcn.service.test;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.epes.laboratory.vcn.application.test.OptimizationApplication;

public class StoreOutputsTask implements JavaDelegate {

	public void execute(DelegateExecution execution) throws Exception {
		//TODO Implement the filling out of the analysis excel
		OptimizationApplication oa = (OptimizationApplication) execution.getVariable("optimizationApplication");
		
		String theoreticalOptimalSequence = (String) execution.getVariable("theoreticalOptimalSequence");
		oa.setTheoreticalOptimalSequence(Integer.parseInt(theoreticalOptimalSequence));
		
		String theoreticalOptimalDistance = (String) execution.getVariable("theoreticalOptimalDistance");
		oa.setTheoreticalOptimalDistance(Float.parseFloat(theoreticalOptimalDistance));
		
		String theoreticalCalculatedEmissions = (String) execution.getVariable("theoreticalCalculatedEmissions");
		oa.setTheoreticalCalculatedEmissions(Float.parseFloat(theoreticalCalculatedEmissions));		
		
		String realSequence = (String) execution.getVariable("realSequence");		
		oa.setRealSequence(Integer.parseInt(realSequence));
		
		String realDistance = (String) execution.getVariable("realDistance");
		oa.setRealDistance(Float.parseFloat(realDistance));
		
		// Calculate the real CO2 emissions
		oa.setRealCalculatedEmissions(Float.parseFloat(realDistance)*oa.getCo2ManagedKnowledge());
		
		// Read excel analysis

		// Append a new line
		
		// Overwrite the excel file with the new line
		
		// Set excel analysis as a field of the process variable optimizationApplication
								
		System.out.println("Service is executed!");
	}
}
